//
//  SFCError.h
//  SVNForCocoa
//
//  Created by Jeremy Pereira on 06/11/2013.
//  Copyright (c) 2013 Jeremy Pereira. All rights reserved.
//
/*!
 *	  @file
 *    @brief Declarations for SFCError class
 */

#import <Foundation/Foundation.h>

/*!
 *    @brief APR error domain is net.jeremyp.apr
 */
extern NSString* const APR_ERROR_DOMAIN;
/*!
 *    @brief SFC error domain is net.jeremyp.sfc
 */
extern NSString* const SFC_ERROR_DOMAIN;
/*!
 *    @brief Error domain for errors from the SVN libraries.
 */
extern NSString* const SVN_ERROR_DOMAIN;

/*!
 *    @brief Errors that can be raied by this library.
 */
enum SFCErrorCode
{
	/*!
	 *    @brief If a method is not implemented.
	 */
	SFC_ERROR_NOT_IMPLEMENTED = 1,
    /*!
     *    @brief Error if an init failed on an object.
     */
    SFC_ERROR_INIT_FAILED = 2,
    /*!
     *    @brief UNable to write to a file or stream
     */
    SFC_ERROR_FILE_WRITE = 3,
    /*!
     *    @brief The selected file or directory is not in a working copy.
     */
    SFC_ERROR_NOT_A_WORKING_COPY = 4,
    /*!
     *    @brief Error raised if we can't understand a diff file.
     */
    SFC_ERROR_DIFF_PARSE = 5,

    /*!
     *    @brief General callback error
     *
     *    Callback blocks return this error (adjusted so svn doesn't confuse it
     *    with already defined svn error codes) to the svn library to signal
     *    something went wrong.  If you need more than just "the callback broke"
     *    use an @c __block @c NSError* or equivalent in the calling context.
     */
    SFC_CALLBACK_ERROR = 6,
};

/*!
 *    @brief SFCError extends NSError to provide conveninece error creation
 *           functions.
 *    @todo  Fix error numbers in domains to  make it easier to pass through 
 *           svn errors.
 */
@interface SFCError : NSError

/*!
 *    @brief Create a NSError from a domain, code and description.
 *
 *    @param domain      Error domain
 *    @param code        Error code within the domain.
 *    @param description Localised desciption.
 *
 *    @return A new NSError.
 */
+(NSError*) errorWithDomain: (NSString*) domain
                       code: (int) code
       localizedDescription: (NSString*) description;

/*!
 *    @brief Make an error that wraps an APR error.
 *
 *    The localised description is set to the APR error text.  The code is the
 *    APR error number.
 *
 *    @param aprStatus The numeric APR status value
 *
 *    @return A new NSError wrapping the APR error.
 */
+(NSError*) aprError: (int) aprStatus;

/*!
 *    @brief Give us a not implemented error.
 *
 *    @param something A message to give more detail.
 *
 *    @return A new NSError.
 */
+(NSError*) notImplemented: (NSString*) something;

/*!
 *    @brief Failed to init an object for some reson.
 *
 *    @param className Name of class of object that failed to init.
 *
 *    @return A new NSError.
 */
+(NSError*) selfInitFail: (NSString*) className;

@end
